package jm.demo.proxy.cglib.wrapper.impl;

import java.util.List;

import com.google.common.collect.ImmutableList;

import jm.demo.auth.domain.Address;
import jm.demo.auth.domain.User;
import jm.demo.proxy.cglib.wrapper.IUserService;

public class UserServiceImpl implements IUserService {
	
	private String shard = "default";
	
	public String getShard() {
		return shard;
	}

	public void setShard(String shard) {
		this.shard = shard;
	}

	@Override
	public User findUserById(int id) {
		User result = null;
		if(id == 1) {
			result = User.getUserOne();
			result.setName(getShard()+ ":" + result.getName());
		} else if (id == 2) {
			result = User.getUserSecond();
			result.setName(getShard()+ ":" + result.getName());
		} 
		return result;
	}

	@Override
	public List<Address> findAddressByUserId(int user_id) {
		return ImmutableList.of(Address.getAddressOne(), Address.getAddressTwo());
	}

	@Override
	public Address findAddressById(int id) {
		// TODO Auto-generated method stub
		return null;
	}

}
